package p.ithorns.tools.excel;

import javax.validation.MessageInterpolator;
import javax.validation.metadata.ConstraintDescriptor;

/**
 * CustomContext
 *
 * @author HtL
 * @date 2024/8/6 17:40
 * @since 1.0.0
 */
public class ValidateContext implements MessageInterpolator.Context {

    private final ConstraintDescriptor<?> descriptor;

    private final Object validatedValue;

    public ValidateContext(ConstraintDescriptor<?> descriptor, Object validatedValue) {
        this.descriptor = descriptor;
        this.validatedValue = validatedValue;
    }

    @Override
    public ConstraintDescriptor<?> getConstraintDescriptor() {
        return descriptor;
    }

    @Override
    public Object getValidatedValue() {
        return validatedValue;
    }

    @Override
    public <T> T unwrap(Class<T> type) {
        return (T) validatedValue;
    }
}